import request from '@/utils/request'
export default {
  //文件下载
  download(fileId) {
    return request({
      url: `/firmwareService/files/download?fileId=${fileId}`,
      method: 'get',
      timeout: 0,
    })
  },
  importExcel(data, callback, fileInfo) {
    return request({
      url: '/firmwareService/dataItem/importExcel',
      method: 'POST',
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      data,
      timeout: 0,
      onUploadProgress: progressEvent => {
        fileInfo && callback && callback(Math.round((progressEvent.loaded / progressEvent.total) * 100), fileInfo)
      },
    })
  },
  //文件上传
  upload(data, callback, fileInfo) {
    return request({
      url: '/firmwareService/files/upload',
      method: 'POST',
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      data,
      timeout: 0,
      onUploadProgress: progressEvent => {
        fileInfo && callback && callback(Math.round((progressEvent.loaded / progressEvent.total) * 100), fileInfo)
      },
    })
  },
  //添加
  add(data) {
    return request({
      url: '/firmwareService/files/add',
      method: 'POST',
      data
    })
  },
  //修改
  edit(data) {
    return request({
      url: '/firmwareService/files/edit',
      method: 'POST',
      data
    })
  },
  //列表查询
  queryList(params) {
    return request({
      url: '/firmwareService/files/queryList',
      method: 'get',
      params
    })
  },

  //列表用户文件查询
  queryFilesListByUserId(id) {
    return request({
      url: `/firmwareService/user/queryFilesListByUserId?userId=${id}`,
      method: 'get'
    })
  },
  //分页查询
  queryPageList(params) {
    return request({
      url: '/firmwareService/files/queryPageList',
      method: 'get',
      params
    })
  },
  //主键删除接口
  del(id) {
    return request({
      url: '/firmwareService/files/del',
      method: 'post',
      data: {
        filesId: id
      }
    })
  },
  //主键批量删除接口
  delList(idList) {
    return request({
      url: '/firmwareService/files/delList',
      method: 'post',
      data: {
        filesIdList: idList
      }
    })
  },
  //功能id查文件
  queryByFuncId(deviceTypeFuncId) {
    return request({
      url: `/firmwareService/files/queryByFuncId?deviceTypeFuncId=${deviceTypeFuncId}`,
      method: 'get'
    })
  },
}